﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Permissions;
using System.Text;

namespace BlueHarvestSnippetGenerator
{
    public class OnAppStartup
    {
        public string Message { get; private set; }

        const string BH_FOLDER = "My BlueHarvest";
        const string SNIPPETS_FOLDER = @"\Snippets";
        const string TUTORIALS_FOLDER = @"\Tutorials";
        const string CSHARP_FOLDER = @"\Csharp";
        const string JAVA_FOLDER = @"\Java";
        private string _startPath = "";


        public OnAppStartup()
        {
            
        }

        public void CreateDirectorysForApp()
        {
            _startPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), BH_FOLDER);

                if (!Directory.Exists(_startPath))
                {
                    try
                    {
                        Directory.CreateDirectory(_startPath);
                        Directory.CreateDirectory(_startPath + SNIPPETS_FOLDER);
                        Directory.CreateDirectory(_startPath + SNIPPETS_FOLDER + CSHARP_FOLDER);
                        Directory.CreateDirectory(_startPath + SNIPPETS_FOLDER + JAVA_FOLDER);
                        Directory.CreateDirectory(_startPath + TUTORIALS_FOLDER);
                        Directory.CreateDirectory(_startPath + TUTORIALS_FOLDER + CSHARP_FOLDER);
                        Directory.CreateDirectory(_startPath + TUTORIALS_FOLDER + JAVA_FOLDER);

                    }
                    catch (Exception msg)
                    {
                        Message = msg.Message;
                    }
                    
                }   
           
        }

        public void ScanDirectoryForNewLanguages()
        {
            var temp = Directory.GetDirectories(_startPath+SNIPPETS_FOLDER);
            
            foreach (var path in temp)
            {
                Message += path+"\n";
            }

        }

    }
}
